/*
 * TimerDelegate.h  0.4.0 / Dec 04, 2010
 *
 * Copyright (c) 2010 - 2011, cute4j.com and contributors.
 *
 * This software is licensed under the LGPL version 2.1 license.
 * A copy of this license is included in the file LICENSE-LGPL.txt.
 */
#ifndef TIMERDELEGATE_H
#define TIMERDELEGATE_H

#include "Cute4jSwing.h"

// TimerDelegate Class. --------------------------------------------------------

/*!
 * \brief Timer Delegate.
 *
 * \author Slobodan Vrkacevic
 * \version 0.4.0
 */
class CUTE4J_EXPORT TimerDelegate : public QObject
{
  Q_OBJECT
protected: // native calls
  TimerDelegate(JNIEnv *env, jobject obj, jint delay, jint initialDelay,
                jboolean singleShot);
  virtual ~TimerDelegate();
public slots: // native calls
  void destroy(JNIEnv *env);
  void setInterval(JNIEnv *env, jint interval);
  void setSingleShot(JNIEnv *env, jboolean singleShot);
public: // native calls
  static void initialize(JNIEnv *env, jclass cls);
  static jlong newInstance(JNIEnv *env, jobject obj, jint delay,
                           jint initialDelay, jboolean singleShot);
protected slots: // native callbacks
  void timeout();
private:
  jweak m_objref;
  QTimer m_timer;
private:
  static jmethodID sm_createMID;
  static jmethodID sm_timeoutMID;
};

// Macro Definition. -----------------------------------------------------------

#define TIMER_DELEGATE (reinterpret_cast<TimerDelegate *>(delegate))

#endif // TIMERDELEGATE_H
